<template>
  <div class="appify">
    <el-form
      :model="dynamicValidateForm"
      ref="dynamicValidateForm"
      label-width="100px"
      class="demo-dynamic"
    >
      <el-form-item prop="email" label="用户名">
        <el-input v-model="dynamicValidateForm.email"></el-input>
      </el-form-item>
      <el-form-item prop="email" label="旧密码">
        <el-input v-model="dynamicValidateForm.oldpwd" type="password"></el-input>
      </el-form-item>
      <el-form-item prop="email" label="新密码">
        <el-input v-model="dynamicValidateForm.newpwd" type="password"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="Update()">确认修改</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      dynamicValidateForm: {
        email: "",
        oldpwd: "",
        newpwd: "",
      },
    };
  },
  methods: {
      Update(){
        let name = this.dynamicValidateForm.email;
        let oldpwd = this.dynamicValidateForm.oldpwd;
        let newpwd = this.dynamicValidateForm.newpwd;
        this.$axios.post("/api/updata",{name,oldpwd,newpwd}).then((res)=>{
          if(res.data.code===2){
            alert(res.data.msg)
          }else{
            alert(res.data.msg)
          }
          console.log(res);
        })
      }
  }
};
</script>

<style lang="scss" scoped>
.appify {
  width: 500px;
  margin: 100px auto;
}
</style>